<template>
  <div class="container">
    <el-dialog
      title="题目预览"
      :visible.sync="flag"
      :before-close="handleClose"
    >
      <el-row :gutter="20">
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【题型】：{{ row.questionType }}
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【编号】：{{ row.id }}
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【难度】：{{ row.difficulty }}
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【标签】：{{ row.tags }}
          </div></el-col
        >
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【学科】：{{ row.subjectName }}
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【目录】：{{ row.directoryName }}
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            【方向】：{{ row.direction }}
          </div></el-col
        >
      </el-row>
      <hr />
      <el-row>
        <el-col> 【题干】：</el-col>
      </el-row>
      <el-row>
        <el-col>{{ row.question }}</el-col>
      </el-row>
      <div id="box">
        <div @click="handleRadio" id="zezao"></div>
        <div v-if="row.questionType !== '简答'">
          <el-row>
            <el-col>单选题 选项：（以下选中的选项为正确答案）</el-col>
          </el-row>
          <el-row>
            <el-col v-for="item in row.options" :key="item.id"
              ><input type="radio" :checked="item.isRight" />
              {{ item.title }}</el-col
            >
          </el-row>
        </div>
        <hr />
        <el-row>
          <el-col
            >【参考答案】：
            <el-button type="danger" @click="isShow = true"
              >视频答案预览</el-button
            ></el-col
          >
          <el-col v-show="isShow">
            <video controls width="360">
              <source :src="row.videoURL" type="video/mp4" /></video
          ></el-col>
        </el-row>
        <hr />
        <el-row>
          <el-col> 【答案解析】：{{ row.answer }}</el-col>
        </el-row>
        <hr />
        <el-row>
          <el-col> 【题目备注】： </el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose" type="primary">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    flag: {
      type: Boolean,
      required: true
    },
    row: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      isShow: false
    }
  },
  methods: {
    handleClose () {
      this.isShow = false
      this.$emit('close')
    },
    handleRadio (e) {
      // console.log(e)
      e.stopPropagation()
    }
  }
}
</script>

<style scoped lang='scss'>
#box {
  position: relative;
  top: 0;
  left: 0;
  #zezao {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 101px;
    opacity: 0;
    z-index: 9;
  }
}
.text {
  font-size: 14px;
}
::v-deep .el-dialog {
  width: 900px;
}
.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}
.dialog-footer {
  text-align: right;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
</style>
